﻿using System;
using Benecura.Services.WebAPI.Proxy.Common;
using RestSharp;

namespace Benecura.Services.WebAPI.Proxy
{
    public class EventRestClient : RestClientBase
    {
        /// <summary>
        /// Retrieve the deserialise generic object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="command"></param>
        /// <returns></returns>
        public override T Retrieve<T>(string command)
        {
            try
            {
                RestRequest request = new RestRequest(RestProxy.EndPoint.Event + command);
                var respond = this.Execute<T>(request);
                return respond.Data;
            }
            catch (Exception ex) { throw ex; }
        }

        /// <summary>
        /// Retrieve the REST response content
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public override string Retrieve(string command)
        {
            try
            {
                RestRequest request = new RestRequest(RestProxy.EndPoint.Event + command);
                var respond = this.Execute(request);
                return respond.Content;
            }
            catch (Exception ex) { throw ex; }
        }
    }
}
